#coding:utf-8
from flask import Flask

from celery import Celery
celery = Celery('yz_task', broker='redis://localhost:6379/9',backend='redis://localhost:6379/6')
@celery.task
def test(a,b):
	return a+b

@celery.task(bind=True)
def long_task(self):
	"""Background task that runs a long function with progress reports."""
	verb = ['Starting up', 'Booting', 'Repairing', 'Loading', 'Checking']
	adjective = ['master', 'radiant', 'silent', 'harmonic', 'fast']
	noun = ['solar array', 'particle reshaper', 'cosmic ray', 'orbiter', 'bit']
	message = ''
	total = random.randint(10, 50)
	for i in range(total):
		if not message or random.random() < 0.25:
			message = '{0} {1} {2}...'.format(random.choice(verb),
			                                  random.choice(adjective),
			                                  random.choice(noun))
		self.update_state(state='PROGRESS',
		                  meta={'current': i, 'total': total,
		                        'status': message})
	return {'current': 100, 'total': 100, 'status': 'Task completed!',
	        'result': 42}